﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Mvc;
using StyleMVVM.DependencyInjection;
using StyleMVVM.DependencyInjection.Impl;

namespace StyleMVVM.MVC.Helpers
{
	public class ControllerExporter : IExportStrategyFactory
	{
		public IExportStrategy CreateStrategy(IDependencyInjectionContainer container,
		                                      Type type,
		                                      IEnumerable<object> attributes,
		                                      bool alreadyExported)
		{
			IExportStrategy returnValue = null;

			if (!alreadyExported)
			{
				if (typeof(IController).IsAssignableFrom(type))
				{
					returnValue = new AttributedExportStrategy(new[] { type.FullName }, type);

					returnValue.ExportedTypes = new List<Type> { type };
				}
			}

			return returnValue;
		}
	}
}